﻿using ASmile.Com;
using ASmile.DBModel;
using ASmile.Win.Extend;
using System;
using System.Windows.Forms;

namespace ASmile.Win.Forms
{
    public partial class FrmCfgPrint : FrmCrud<Sys_PrintConfig>
    {
        public FrmCfgPrint()
        {
            InitializeComponent();
        }

        protected override FrmBaseEdit CreateAddForm()
        {
            var frm = new FrmCfgPrintEdit();
            frm.SearchFormName = SearchArg.TagData?.ToString();
            frm.OwnerForm = Owner;
            frm.DgvRowCount = dgv.RowCount;
            return frm;
        }

        IPrintConfigBLL BLL { get; } = ObjectFactory.GetObject<IPrintConfigBLL>("PrintConfigBLL");

        protected override IBLLCrud<Sys_PrintConfig> BLLObj2 => BLL;

        private void FrmPrintConfig_Load(object sender, EventArgs e)
        {
            if (Owner is IFormContainer dgvContainer)
            {
                SearchArg.TagData = dgvContainer.ContainerName;

                BtnSearch_Click(sender, e);
            }
            if (IsManager)
            {
                toolStripTop.LoopItem(SetRights);
                void SetRights(ToolStripItem item)
                {
                    if (!item.Enabled) item.Enabled = item.Visible = true;
                }
            }
        }
    }
}